package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.CustomerPriceView;
import com.sl.au.repository.ExdeCustomerPriceViewRepository;
import com.sl.au.service.ExdeCustomerPriceViewService;

@Service("ExdeCustomerPriceViewService")
@Transactional
public class ExdeCustomerPriceViewServiceImpl implements ExdeCustomerPriceViewService{
	
	@Autowired
	ExdeCustomerPriceViewRepository exdeCustomerPriceViewRepository;
	
	@Override
	public ExdeCustomerPriceViewRepository exdeCustomerPriceViewRepository() {
		// TODO Auto-generated method stub
		return this.exdeCustomerPriceViewRepository;
	}

	@Override
	public List<CustomerPriceView> getPriceList(int start, int size, String key) {
		// TODO Auto-generated method stub
		Page<CustomerPriceView> pages = null;
		Pageable pageable = new PageRequest(start / size, size, Sort.Direction.DESC, "createTime");
		pages = exdeCustomerPriceViewRepository.getPriceList(key,pageable);
		return pages.getContent();
	}

	@Override
	public long getAllPriceCount(String key) {
		// TODO Auto-generated method stub
		return exdeCustomerPriceViewRepository.getAllPriceCount(key);
	}

}
